<div class="row page-heading">
  <div class="col-xs-12">
    <h2><%= model_human_name %>管理</h2>
    <ol class="breadcrumb">
      <li class="active">
        <%= model_human_name %>管理
      </li>
    </ol>
  </div>
</div>

<div class="row">
  <div class="col-lg-12">
    <div class="wrapper-content">
      <%%= ibox do %>
        <%%= ibox_title '<%= model_human_name %>列表' do %>
          <%%= link_to '添加<%= model_human_name %>', <%= "new_#{prefixed_plain_model_url}_path" %>, class: 'btn btn-xs btn-w-m btn-primary' %>
        <%% end %>
        <%%= ibox_content do %>
          <%% if @<%= plural_name %>.empty? %>
            <p class="alert alert-warning">
              没有符合条件的<%= model_human_name %>
            </p>
          <%% else %>
            <%%= admin_table do %>
              <thead>
                <tr>
                  <th></th>
                  <%- attributes.each do |attribute| -%>
                  <th><%%= <%= class_name %>.human_attribute_name :<%= attribute.name %> %></th>
                  <%- end -%>
                  <th>操作</th>
                </tr>
              </thead>
              <tbody>
                <%% @<%= plural_name %>.each_with_index do |<%= singular_name %>, i| %>
                  <tr>
                    <td><%%= index_of_item(i, page_size) %></td>
                    <%- attributes.each do |attribute| -%>
                    <td><%%= <%= singular_name %>.<%= attribute.name %> %></td>
                    <%- end -%>
                    <td>
                      <%%= light_edit_button '编辑', [:edit, <%= class_path_array %> <%= singular_name %>] %>
                      <%%# light_method_button_to '删除', [<%= class_path_array %> <%= singular_name %>], 'trash', 'delete', {confirm: '确认删除？'} %>
                      <%- if active_enabled? %>
                      <%% if <%= singular_name %>.active %>
                        <%%= light_button_to '启用', [<%= class_path_array %> <%= singular_name %>, :active], 'pause', method: :delete %>
                      <%% else %>  
                        <%%= light_button_to '暂停', [<%= class_path_array %> <%= singular_name %>, :active], 'play', method: :post %>
                      <%% end %>  
                      <%- end -%>
                      <%- if recommend_enabled? %>
                      <%% if <%= singular_name %>.recommended %>
                        <%%= light_button_to '取消', [<%= class_path_array %>, <%= singular_name %>, :recommend], 'thumbs-down', method: :delete %>
                      <%% else %>  
                        <%%= light_button_to '推荐', [<%= class_path_array %>, <%= singular_name %>, :recommend], 'thumbs-up', method: :post %>
                      <%% end %>
                      <%- end -%>
                    </td>
                  </tr>
                <%% end %>
              </tbody>
            <%% end %>
            <%%= paginate @<%= plural_name %> %>
          <%% end %>
        <%% end %>
      <%% end %>
    </div>
  </div>
</div>
